package org.imlinker.util;

public class StringUtils {

	public static boolean isNotEmpty(String content) {

		if (content == null) {
			return false;
		}

		if (content.trim().length() == 0) {
			return false;
		}

		return true;
	}

	public static boolean isEmpty(String content) {
		if (content == null) {
			return true;
		}

		if (content.trim().length() == 0) {
			return true;
		}

		return false;
	}

	public static boolean contains(String from, char c) {

		if (from.indexOf(c) >= 0) {
			return true;
		}

		return false;
	}

	public static String substringBeforeLast(String str, String c) {

		int i = str.lastIndexOf(c);
		if (i >= 0) {
			return str.substring(0, i);
		}

		return "";
	}

	public static String substringAfterLast(String str, String c) {
		int i = str.lastIndexOf(c);

		if (i >= 0) {
			return str.substring(i + 1);
		}

		return "";
	}

	public static boolean equal(String astr, String bstr) {
		String a = astr.trim();
		String b = bstr.trim();

		if (a.endsWith(b) && a.startsWith(b)) {
			return true;
		}
		return false;
	}

}
